package org.dromara.common.satoken.config;

import cn.dev33.satoken.dao.SaTokenDao;
//import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpInterface;
//import cn.dev33.satoken.stp.StpLogic;
import org.dromara.common.core.factory.YmlPropertySourceFactory;
import org.dromara.common.satoken.core.dao.PlusSaTokenDao;
import org.dromara.common.satoken.core.service.SaPermissionImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

/**
 * sa-token 配置
 * Spring config类，注入StpLogic，StpInterface，SaTokenDao
 * @author ahdkk
 */
@AutoConfiguration
@PropertySource(value = "classpath:common-satoken.yml", factory = YmlPropertySourceFactory.class)
public class SaTokenConfig {

//    @Bean
//    public StpLogic getStpLogicJwt() {
//        // Sa-Token 整合 jwt (简单模式) 不同模式策略对比见：https://sa-token.cc/doc.html#/plugin/jwt-extend
//        return new StpLogicJwtForSimple();
//    }

    /**
     * 权限数据加载源接口(使用bean注入方便用户替换)
     */
    @Bean
    public StpInterface stpInterface() {
        return new SaPermissionImpl();
    }

    /**
     * 自定义dao层存储
     */
    @Bean
    public SaTokenDao saTokenDao() {
        return new PlusSaTokenDao();
    }

}
